<?
#####################################################
#  COPYRIGHT NOTICE
#####################################################
# In the following statements, the term "this 
# program" refers to all files associated with the
# execution and distribution of Adtrackz.
#
# This Program is Copyright 2004 Jonah Klimack.
# All Rights Reserved. 
#
# Selling the code for this program, modifying 
# and/or redistributing the code for this program
# in part or in whole over the Internet or in any 
# other medium is expressly forbidden. Violators
# will be prosecuted to the fullest extent of the law
# Copyright and header information may not be
# modified.
#
# This program is distributed "as is" and without 
# warranty of any kind, either express or implied.
# In no event shall the liability of Jonah Klimack 
# for any damages, losses and/or causes of 
# action exceed the total amount paid by the 
# user for this software.		
#####################################################
# DO NOT MODIFY ANYTHING IN THIS FILE
#####################################################


require "header.php";
require "submenu.php";

$campaign = mysql_fetch_row(mysql_query("select * from adtrackz_campaigns where ID='$cID'"));
if (!$limit)
	$limit = 10;

?>

<table width="100%">
<tr>
	<td>
		<p class="small" align="left">Campaigns > <?=$campaign[2]?> > Referring Urls</p>
	</td>
	<td>
		<?load_submenu($cID,$campaign[2])?>
	</td>
</tr>
</table>


<p class="heading">
Referring urls for <?=ucfirst($campaign[2])?>
</p>

<p>
A referring url is the website your visitor was on before clicking to your website. If a visitor clicked on your url from email, or a bookmark, the referring url is shown as none.
</p>
<p align=center>
Show [ 
<a href="dstats-urls.php?cID=<?=$cID?>&limit=10">10</a> | 
<a href="dstats-urls.php?cID=<?=$cID?>&limit=20">20</a> | 
<a href="dstats-urls.php?cID=<?=$cID?>&limit=50">50</a> | 
<a href="dstats-urls.php?cID=<?=$cID?>&limit=100">100</a> | 
<a href="dstats-urls.php?cID=<?=$cID?>&limit=500">All</a> 
] Referrers
</p>

<form action="dstats-urls.php" method="post">
<input type="hidden" name=cID value=<?=$cID?>>

<table width="580" border="1" cellspacing="0" cellpadding="5" align="center" bordercolor="#e0e0e0">
<tr>
	<td class="tbhead1">Url</td>
	<td class="tbhead1">Clicks</td>
	<td class="tbhead1">&nbsp;</td>
</tr>
<?
$urls = mysql_query("select referringurl from adtrackz_clicks where campaignID='$cID'");
if (!mysql_num_rows($urls))
	echo "<tr><td colspan=7>There are no referring urls to display.</td></tr></table>";
else
{
	for($i=0;$i<mysql_num_rows($urls);$i++)
	{
		$url = mysql_fetch_row($urls);
		$urldata[$i] = $url[0];
	}
	$urldata = array_count_values($urldata);
	arsort($urldata);

	$c = 1;
	foreach($urldata as $key => $value)
	{
		if ($c <= $limit)
			$urldata2[$key] = $value;
		else
			break;
		$c++;
	}

	$max = max($urldata2);
	foreach($urldata2 as $key => $value)
	{
		if ($value == $max)
			$width = 250;
		else
			$width = $value / $max * 350;
		$wkey = wordwrap($key, 50, "<br>", 1);

print <<<END
<tr>
	<td class="tb1"><a href=$key target=_ref>$wkey</a></td>
	<td class="tb1">$value</td>
	<td><img src=bar.gif height=10 width=$width></td>
</tr>
END;
	}
}
?>

</table>
</form>
<br>


<?
require "footer.php";


?>